package com.hc.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hc.domain.BlogCategoryCharge;
import com.hc.dto.ListBlogCategoryChargeDTO;
import com.hc.vo.BlogCategoryChargeVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface BlogCategoryChargeMapper extends BaseMapper<BlogCategoryCharge> {

    /**
     * 增加博客专栏费用
     *
     * @param blogCategoryChargeVO
     * @return
     */
    @Insert("INSERT INTO tb_blog_category_charge (price1, price2, frequency, amount, intro, category_id, create_time) VALUES" +
            " (#{blogCategoryChargeVO.price1} ,#{blogCategoryChargeVO.price2} ,#{blogCategoryChargeVO.frequency} ,#{blogCategoryChargeVO.amount} ,#{blogCategoryChargeVO.intro} ,#{blogCategoryChargeVO.categoryId} ,now())")
    int insertBlogCategoryCharge(@Param("blogCategoryChargeVO") BlogCategoryChargeVO blogCategoryChargeVO);

    /**
     * 根据id查找博客专栏费用的简介
     *
     * @param id 客专栏费用记录的编号
     * @return
     */
    @Select("SELECT intro FROM tb_blog_category_charge WHERE id = #{id} ")
    String selectBlogCategoryChargeIntroById(@Param("id") Integer id);

    /**
     * 删除指定id的博客专栏费用
     *
     * @param id 客专栏费用记录的编号
     * @return
     */
    @Delete("DELETE FROM tb_blog_category_charge WHERE id=#{id} ")
    int deleteBlogCategoryChargeById(@Param("id") Integer id);

    /**
     * 查询博客类别中收费博客专栏的信息
     *
     * @param userId 值为null时表示查询所有的收费专栏，值不为空时表示查询指定用户的收费专栏
     * @return
     */
    List<ListBlogCategoryChargeDTO> selectBlogCategoryChargeDTOs(@Param("userId") Integer userId);

}
